import { Controller, Get, Post, Body } from '@nestjs/common';
import { MenuService } from './menu.service';
import { CurrentUser } from '@/common/decorator';
import { CreateMenuDto } from './dto/create-menu.dto';

@Controller('menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) {}

  /**
   * 根据用户id获取菜单
   */
  @Get()
  async findAllListByUserId(@CurrentUser() user) {
    return this.menuService.findAllListByUserId(user.id);
  }

  /**
   * 添加菜单
   */
  @Post()
  async addMenu(@Body() menu: CreateMenuDto, @CurrentUser() user) {
    return await this.menuService.addMenu(menu, user.id);
  }
}
